# -*- Python -*-

import os

def get_required_attr(config, attr_name):
  attr_value = getattr(config, attr_name, None)
  if not attr_value:
    lit_config.fatal(
      "No attribute %r in test configuration! You may need to run "
      "tests from your build directory or add this attribute "
      "to lit.site.cfg " % attr_name)
  return attr_value

# Setup source root.
ubsan_lit_tests_dir = get_required_attr(config, 'ubsan_lit_tests_dir')
config.test_source_root = os.path.join(ubsan_lit_tests_dir, 'TestCases')

def DisplayNoConfigMessage():
  lit_config.fatal("No site specific configuration available! " +
                   "Try running your test from the build tree or running " +
                   "make check-ubsan")

# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']

# UndefinedBehaviorSanitizer tests are currently supported on
# Linux and Darwin only.
if config.host_os not in ['Linux', 'Darwin']:
  config.unsupported = True

config.pipefail = False
